package com.niiwoo.civet.trade.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/**
 * @Author: wuke
 * @Description: 法大大模板相关枚举
 * @Date: Created in 10:56 2017/11/18
 */
public class FadadaContractTemplateEnum {

    /**
     * 模板类型枚举：1、极速借借款,2、代扣,3、团贷网发标,4、反担保,5、仲裁,6、送达回证 7.考拉法大大债仅转让合同,8.借款授权委托书,9.考拉理财授权开户委托书
     * 10.委托授权协议,11.风险提示书
     * 12, "团贷授权开户委托书" 13, "借新还旧委托授权书"(老系统后期新增)
     */
    @AllArgsConstructor
    @Getter
    public enum TemplateTypeEnum {
        FAST_LOAN((byte)1,"极速借借款"),
        WITHHOLD((byte)2,"代扣"),
        TUANDAI((byte)3,"团贷网发标"),
        ANTI_GUARANTEE((byte)4,"反担保"),
        ARBITRATION((byte)5,"仲裁"),
        RETURN_CERTIFICATE((byte)6,"送达回证"),
        KAOLA_TRANSFER_CONTRACT((byte)7,"考拉法大大债仅转让合同"),
        LOAN_AUTH_PROXY((byte)8,"借款授权委托书"),
        LOAN_ACCOUNT_PROXY((byte)9,"考拉理财授权开户委托书"),
        CONSIGNOR_AUTHORIZE_PROTOCOL((byte)10,"委托授权协议"),
    	RISK_PROMPT((byte)11,"风险提示书"),
    	TD_AUTH((byte)12, "团贷授权开户委托书"),
        KAOLA_WITHHOLD((byte)14,"考拉理财还款代扣合同"),

        ORG_COMPANY_FAST_LOAN((byte)15,"机构企业极速借居间借款合同-鸿特"),
        COMPANY_WITHHOLD((byte)16,"企业还款服务委托书"),
        ORG_PERSONAL_FAST_LOAN((byte)17,"机构个人极速借居间借款合同-鸿特"),
        TO8TO_FAST_LOAN((byte)18,"土巴兔极速借居间借款合同"),
        CREDITOR_TRANSFER_PROTOCOL((byte)19,"债权转让协议"),
        CREDITOR_TRANSFER_RISK_PROMPT((byte)20,"债权转让服务风险提示书"),
        JUN_TUO_COMPANY_FAST_LOAN((byte)21,"俊拓企业居间借款合同"),
        JUN_TUO_PERSONAL_FAST_LOAN((byte)22,"俊拓个人居间借款合同"),
        CREDIT_ENQUIRY_AUTHORIZATION((byte)23,"征信查询授权书"),
        INTELLIGENCE_RISK_PROMPT((byte)24,"智能投风险提示书"),
        INTELLIGENT_SERVICE_PROTOCOL((byte)25,"智能投服务协议"),
        INFORMATION_INQUIRY_AUTHORIZATION((byte)26,"信息查询授权书"),
        INFORMATION_CONSULTING_SERVICE_PROTOCOL((byte)27,"信息咨询服务协议"),
        ;

        private Byte type;
        private String desc;

        public static TemplateTypeEnum getByType(byte type) {
            Optional<TemplateTypeEnum> templateType =
                    Arrays.stream(values()).filter(value -> value.getType() == type).findFirst();
            return templateType.isPresent() ? templateType.get() : null;
        }
    }

    /**
     * 签署步骤枚举(1.借款；2.投资；3放款；)
     */
    @AllArgsConstructor
    @Getter
    public enum SignStepEnum {
        LOAN((byte)1,"借款"),
        INVEST((byte)2,"投资"),
        LEND((byte)3,"放款");

        private Byte step;
        private String desc;

        public static SignStepEnum getByStep(byte step) {
            Optional<SignStepEnum> sgnStepEnum =
                    Arrays.stream(values()).filter(value -> value.getStep() == step).findFirst();
            return sgnStepEnum.isPresent() ? sgnStepEnum.get() : null;
        }
    }

    /**
     * 状态枚举（0：开启， 1：关闭）
     */
    @AllArgsConstructor
    @Getter
    public enum StatusEnum {
        OPEN((byte)0,"开启"),
        CLOSE((byte)1,"关闭");

        private Byte status;
        private String desc;

        public static StatusEnum getByStatus(byte status) {
            Optional<StatusEnum> statusEnum =
                    Arrays.stream(values()).filter(value -> value.getStatus() == status).findFirst();
            return statusEnum.isPresent() ? statusEnum.get() : null;
        }
    }
}
